﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Core.Model;

namespace EzDesk.Apps.ServiceImpl.Repositories.Mock
{
    public class Mock_Repository<T> : IRepository<T>
        where T : IModel
    {
        /// <summary>
        /// 初始化一些基本的测试数据的方法
        /// </summary>
        protected virtual void initialize()
        {
        }

        protected Mock_Storage<T> innerStorage = new Mock_Storage<T>();

        public void SetStorageData(List<T> data)
        {
            innerStorage.SetInnerStorage(data);
        }

        public Guid Add(T model, bool saveChanges)
        {
            return innerStorage.Add(model, saveChanges);
        }

        public T GetById(Guid id)
        {
            return innerStorage.GetById(id);
        }

        public IQueryable<T> GetAll()
        {
            return innerStorage.GetAll();
        }

        public void Delete(Guid id, bool saveChanges)
        {
            innerStorage.Delete(id, saveChanges);
        }

        public void Update(T model, bool saveChanges)
        {
            innerStorage.Update(model, saveChanges);
        }

        public void SaveChanges()
        {
            innerStorage.SaveChanges();
        }
    }
}
